package com.hdaccp.foodsales.controller;

import com.hdaccp.foodsales.entity.Xiaoshouls;
import com.hdaccp.foodsales.service.xiaoshoulsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/xiaoshouls")
@Scope("prototype")
public class xiaoshoulsController {
    @Autowired
    private xiaoshoulsService xiaoshoulsService;

    @RequestMapping("/addls")
    @ResponseBody
    public int addls(Xiaoshouls xiaoshouls){
        return xiaoshoulsService.addls(xiaoshouls);
    }


    @RequestMapping("/query")
    @ResponseBody
    public Map<String,Object> querySearch(String huoname, int offset, int limit){
        Map<String,Object> map = new HashMap<>() ;
        map.put("rows", xiaoshoulsService.findAll(huoname,offset,limit)) ;
        map.put("total", xiaoshoulsService.findTotalCount(huoname)) ;
        return  map ;
    }

    @RequestMapping("/all")
    @ResponseBody
    public boolean all(String huoname, int offset, int limit){
        boolean isok = false;
        if (xiaoshoulsService.findAll(huoname,offset,limit).size() == 0){
            isok = true;
        }
        return  isok ;
    }

}
